package com.yuandian.business.monitor.controller;

import com.yuandian.bpm.common.core.util.R;
import com.yuandian.business.monitor.service.IBusiAlarmTrendService;
import com.yuandian.api.business_monitor.po.AlarmDistribteMapParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;

/**
 * 访问告警分布图
 * *
 *
 * @author zhoutian
 * @date 2020/9/27 10:26
 */
@Api(value = "indexDetail", tags = "首页详情接口")
@RestController
@RequestMapping("/alarm/busiAlarmTrend")
public class VisitAlarmDistribteMapController {

    @Autowired
	IBusiAlarmTrendService busiAlarmTrendService;



    /**
     * 查询告警类型占比信息
     *
     * @param params params
     * @return 告警趋势图VO
     */
	@ApiImplicitParams({
			@ApiImplicitParam(name = "currentTime",  	value = "当前时间", paramType = "query",  required = true,    dataType = "String"),
			@ApiImplicitParam(name = "systemId",   		value = "系统ID", paramType = "query",  required = true,    dataType = "Integer"),
			@ApiImplicitParam(name = "pageNum",   	 	value = "页码", 	paramType = "query",  required = true,    dataType = "Long"),
			@ApiImplicitParam(name = "pageSize", 	 	value = "每页大小", 	paramType = "query",  required = true,    dataType = "Long")
	})
	@ApiOperation(value = "查询告警类型占比信息", notes = "查询告警类型占比信息")
    @GetMapping("/getAlarmRatio")
    public R getAlarmRatio(@Validated AlarmDistribteMapParams params) throws ParseException {
        Object[] list = busiAlarmTrendService.queryAlarmRatioMap(params);
        return R.ok(list);
    }


    /**
     * 查询节点占比信息
     *
     * @param params params
     * @return 告警趋势图VO
     */
	@ApiImplicitParams({
			@ApiImplicitParam(name = "currentTime",  	value = "当前时间", paramType = "query",  required = true,    dataType = "String"),
			@ApiImplicitParam(name = "systemId",   		value = "系统ID", paramType = "query",  required = true,    dataType = "Integer"),
			@ApiImplicitParam(name = "pageNum",   	 	value = "页码", 	paramType = "query",  required = true,    dataType = "Long"),
			@ApiImplicitParam(name = "pageSize", 	 	value = "每页大小", 	paramType = "query",  required = true,    dataType = "Long"),
			@ApiImplicitParam(name = "alarmTypeId", 	value = "告警类型(告警指标)id",paramType = "query",  required = true,  dataType = "Long")
	})
	@ApiOperation(value = "查询节点占比信息", notes = "查询节点占比信息")
    @GetMapping("/getNodeRatio")
    public R getNodeRatio(@Validated  AlarmDistribteMapParams params) throws ParseException {

        Object[] list = busiAlarmTrendService.queryNodeRatioMap(params);
        return R.ok(list);
    }


    /**
     * 访问量告警分类网端详情列表
     *
     * @param params params
     * @return 告警占比gridVO
     */
	@ApiImplicitParams({
			@ApiImplicitParam(name = "currentTime",  	value = "当前时间", paramType = "query",  required = true,    dataType = "String"),
			@ApiImplicitParam(name = "systemId",   		value = "系统ID", paramType = "query",  required = true,    dataType = "Integer"),
			@ApiImplicitParam(name = "pageNum",   	 	value = "页码", 	paramType = "query",  required = true,    dataType = "Long"),
			@ApiImplicitParam(name = "pageSize", 	 	value = "每页大小", 	paramType = "query",  required = true,    dataType = "Long"),
			@ApiImplicitParam(name = "alarmTypeId", 	 	value = "告警类型", 	paramType = "query",  required = true,    dataType = "Integer"),
			@ApiImplicitParam(name = "segmentId", 	value = "网端id",paramType = "query",  required = true,  dataType = "Long")
	})
	@ApiOperation(value = "访问量告警分类网端详情列表", notes = "访问量告警分类网端详情列表")
    @GetMapping("/getNodeProportion")
    public R getNodeProportion(@Validated AlarmDistribteMapParams params) {
        return R.ok(busiAlarmTrendService.queryNodeProportion(params));
    }


    /**
     * 访问量告警分类详情列表
     *
     * @param params params
     * @return 告警占比gridVO
     */
	@ApiImplicitParams({
			@ApiImplicitParam(name = "currentTime",  	value = "当前时间", paramType = "query",  required = true,    dataType = "String"),
			@ApiImplicitParam(name = "systemId",   		value = "系统ID", paramType = "query",  required = true,    dataType = "Integer"),
			@ApiImplicitParam(name = "pageNum",   	 	value = "页码", 	paramType = "query",  required = true,    dataType = "Long"),
			@ApiImplicitParam(name = "pageSize", 	 	value = "每页大小", 	paramType = "query",  required = true,    dataType = "Long"),
			@ApiImplicitParam(name = "alarmTypeId", 	 	value = "告警类型", 	paramType = "query",  required = true,    dataType = "Integer"),
			@ApiImplicitParam(name = "segmentId", 	value = "网端id",paramType = "query",  required = true,  dataType = "Long")
	})
	@ApiOperation(value = "访问量告警分类详情列表", notes = "访问量告警分类详情列表")
    @GetMapping("/getTypeProportion")
    public R getTypeProportion(@Validated  AlarmDistribteMapParams params) {
        return R.ok(busiAlarmTrendService.queryTypeProportion(params));
    }


    /**
     * 导出列表Excel文件
     *
     * @param params params
     * @return 通用返回对象
     */
	@ApiImplicitParams({
			@ApiImplicitParam(name = "currentTime",  	value = "当前时间", paramType = "query",  required = true,    dataType = "String"),
			@ApiImplicitParam(name = "systemId",   		value = "系统ID", paramType = "query",  required = true,    dataType = "Integer"),
			@ApiImplicitParam(name = "pageNum",   	 	value = "页码", 	paramType = "query",  required = true,    dataType = "Long"),
			@ApiImplicitParam(name = "pageSize", 	 	value = "每页大小", 	paramType = "query",  required = true,    dataType = "Long"),
			@ApiImplicitParam(name = "alarmTypeId", 	 	value = "告警类型", 	paramType = "query",  required = true,    dataType = "Integer"),
			@ApiImplicitParam(name = "segmentId", 	value = "网端id",paramType = "query",  required = true,  dataType = "Long")
	})
	@ApiOperation(value = "导出列表告警类型/节点占比Excel文件", notes = "导出列表告警类型/节点占比Excel文件")
    @PostMapping("/export")
    public void export(@RequestBody AlarmDistribteMapParams params, HttpServletResponse response) {
        busiAlarmTrendService.export(params, response);
    }

}
